package com.yin.controller;




import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yin.mapper.TestMapper;
import com.yin.pojo.Test;
import com.yin.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
public class mainController {
    @Autowired
    private TestService testService;

    @RequestMapping({"/index", "/",""})
    public String index(){
        return "dashboard";
    }

    @RequestMapping("/SoftwareEngineering")
    public String SoftwareEngineering(){
        return "SoftwareEngineering";
    }

    @RequestMapping("/Artificial")
    public String ArtificialIntelligence(){
        return "ArtificialIntelligence";
    }

    @RequestMapping("/BigData")
    public String BigData(){
        return "BigData";
    }

    @RequestMapping("/InformationSecurity")
    public String InformationSecurity(){
        return "InformationSecurity";
    }

    @RequestMapping("/Network")
    public String Network(){
        return "NetworkCommunication";
    }

    @RequestMapping("/Operation")
    public String Operation(){
        return "Operation";
    }

    @RequestMapping("/SoftwareTesting")
    public String SoftwareTesting(){
        return "SoftwareTesting";
    }

    @RequestMapping("/redic")
    public String top(){
        return "redirect:index";
    }

    @RequestMapping("/list")
    public String list(String jobName,Model model){
        QueryWrapper<Test> wrapper = new QueryWrapper<>();
        List<com.yin.pojo.Test> list = testService.list(wrapper.like("jname", jobName)
                .or().like("ctype", jobName)
                .or().like("jname", jobName)
                .or().like("tag",jobName));
        model.addAttribute("name",jobName);
        model.addAttribute("list",list);
        return "list";
    }





}
